package com.su.lightthings.fragment

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.GridLayoutManager
import com.su.lightthings.adapter.HomeFunctionAdapter
import com.su.lightthings.base.BaseFragment
import com.su.lightthings.databinding.FragmentHomeBinding
import com.su.lightthings.utils.Cons
import com.su.lightthings.view.GridSpacingItemDecoration
import com.su.lightthings.view.LinearSpacingItemDecoration

class HomeFragment : BaseFragment<FragmentHomeBinding>() {
    override fun getViewBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentHomeBinding = FragmentHomeBinding.inflate(layoutInflater)

    private val mAdapter: HomeFunctionAdapter by lazy {
        HomeFunctionAdapter()
    }

    override fun initViews() {
        binding.rv.apply {
            adapter = mAdapter
            layoutManager = GridLayoutManager(requireContext(), 2)
            isNestedScrollingEnabled = false
            addItemDecoration(GridSpacingItemDecoration(2,10,false))
        }
        mAdapter.submitList(Cons.HomePage.homeFunctionList)
    }

}